package com.lucky.contract.controller;

import com.lucky.contract.ContractApplication;
import com.lucky.contract.entity.ContractType;
import com.lucky.contract.entity.SysUser;
import com.lucky.contract.service.ContractTypeService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping(value = "/main")
public class MainController extends BaseController<SysUser>{

    private static final Logger log = LoggerFactory.getLogger(ContractApplication.class);

    @Resource
    private ContractTypeService contractTypeService;

    @RequestMapping(value = "/index")
    public ModelAndView mainIndex(){
        ModelAndView modelAndView = new ModelAndView();
        Map<String, Object> map = new HashMap<>();
        try {
            List<ContractType> list = contractTypeService.queryList(map);
            modelAndView.addObject("menus",list);
            modelAndView.addObject("loginUser",this.getLoginUser());
            modelAndView.setViewName("/main/index");
        } catch (Exception e) {
            e.printStackTrace();
            log.info("获取合同类型列表失败，原因：" + e.getMessage());
        }
        return modelAndView;
    }
}

